<?php

class Service {

	function __construct( $service ) {
		$this->servicename = $service['servicename'];
	        $this->serviceurl = $service['serviceurl'];
		$this->searchurl = $service['searchurl'];
	}

	public function getPublicTimeline( $user, $count ) {
	
		$wikierror = null;
		$curl = new Curl();

	        $params = array(
        	        'screen_name' => $user,
                	'count' => $count
                 );

		switch ( $this->servicename ) {
			case 'twitter':
				$url = $this->serviceurl . 'statuses/user_timeline.json';
				break;
			case 'identi.ca':
				$url = $this->serviceurl . 'statuses/public_timeline.json';
				break;
		}

        	$results = $curl->get( $url, $params );
		
	        if ( WikiError::isError( $results ) ) {
        	        return $results;
		} else {		
		 	$response = json_decode( $results );
//			$error = $response->error;
			if ( isset( $response->error ) ) {
				$wikierror = new WikiError( $response->error );
				return $wikierror;
			} else {
				return $response;
			}			
		}

	}

}
